package com.xdb.sqlparser.dialect.oracle.ast.statement;

import java.util.ArrayList;
import java.util.List;

import com.xdb.sqlparser.ast.SQLExpr;
import com.xdb.sqlparser.dialect.oracle.ast.statement.OracleSelectPivot.Item;
import com.xdb.sqlparser.dialect.oracle.visitor.OracleASTVisitor;

public class OracleSelectUnPivot extends OracleSelectPivotBase {

	private NullsIncludeType nullsIncludeType;
	private final List<SQLExpr> items = new ArrayList<SQLExpr>();

	private final List<OracleSelectPivot.Item> pivotIn = new ArrayList<Item>();

	public OracleSelectUnPivot() {

	}

	public void accept0(OracleASTVisitor visitor) {
		if (visitor.visit(this)) {
			acceptChild(visitor, this.items);
			acceptChild(visitor, this.pivotIn);
		}
		visitor.endVisit(this);
	}

	public List<OracleSelectPivot.Item> getPivotIn() {
		return this.pivotIn;
	}

	public List<SQLExpr> getItems() {
		return this.items;
	}

	public NullsIncludeType getNullsIncludeType() {
		return this.nullsIncludeType;
	}

	public void setNullsIncludeType(NullsIncludeType nullsIncludeType) {
		this.nullsIncludeType = nullsIncludeType;
	}

	public static enum NullsIncludeType {
		INCLUDE_NULLS, EXCLUDE_NULLS;

		public static String toString(NullsIncludeType type) {
			if (INCLUDE_NULLS.equals(type)) {
				return "INCLUDE NULLS";
			}
			if (EXCLUDE_NULLS.equals(type)) {
				return "EXCLUDE NULLS";
			}

			throw new IllegalArgumentException();
		}
	}
}
